{template header}

<script type="text/javascript" src="{SITE_URL}public/js/jquery.upload.v2.js"></script>

<div class="container">


<div class="row">


<div class="col-md-8">


    <div class="panel panel-default">
        <div class="panel-body">


<div style="padding-top:10px" >
<ul>
	{loop $arrDuty $key $item}
	<section  style="margin: 5px 0px 0px;
    padding: 16px;
    margin:1em 0;
    border-style: none;
    line-height: 25px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow:0px 2px 8px rgb(153, 153, 153)" id="shifu_c_034" donone="shifuMouseDownCard(&#39;shifu_c_034&#39;)">
	<li>

		<div style="display: flex"><div class="userimg"><img class="img-circle" src="{$item[user][face]}" width="18"  alt="{$item['user']['username']}" title="{$item['user']['username']}" /></div><div style="padding-left: 5px">{$item[user][username]}</div></div>

		<div class="duty_title">

			<div class="title">

				<div class="content" style="padding-top: 10px;" >
				<i class="fa fa-sticky-note-o"></i>	{if $item['endtime']==0}{php echo date('Y-m-d',$item['begintime'])}{else}{php echo date('Y-m-d H:i',$item['begintime'])}至{php echo date('H:i',$item['endtime'])}{/if}在{php echo $item['address']}执行{$item['cate']}，{if $item['commute']==0}服务{php echo $item['period']}小时{else}实际服务{$item['period']}小时，通勤时间{php echo $item['commute']}小时，合计耗时{php echo $item['term']}小时{/if}。

				</div>
				<div class="content" style="padding-top: 10px;">
					{php echo delempty($item['job'])}



				</div>




</div>
</li>
</section>
{/loop}
</ul>


<div class="clear"></div>
<div class="page">{$pageUrl}</div>



</div>









<script>



	//隐藏列表，显示登记表单
	function showdutyform(){
		$('#duty_list').hide();
		$('#do_duty_form').show();
	}


	//筛选分馆
	function jumpto(url,groupid){

       window.location.href=url+'&groupid='+groupid;
	}



	//统计截止时间表单
	function doDateForm(){

			var content = $("#do_date_form").html();
			tsNotice(content);

	}



	//登记服务填写表单
	function doDutyForm(userid){

		if(userid==0){
			tsNotice('请登录后再操作！');
		}else{

			var content = $("#do_duty_form").html();
			tsNotice(content);
		}
	}
	//删除服务记录
	function delDuty(dutyid){


		if (confirm('删除这条服务记录吗？')) {

			$.ajax({
				type: "POST",
				url: siteUrl+"index.php?app=user&ac=do&ts=del",
				data: "dutyid="+dutyid,
				beforeSend:function(){
				},
				success:function(result){
					if(result == '1'){
						window.location.reload();
					}
				}
			});

		}
	}
	//核定服务记录
	function verify(dutyid){


		if (confirm('核定这条服务记录吗？')) {

			$.ajax({
				type: "POST",
				url: siteUrl+"index.php?app=user&ac=do&ts=verify",
				data: "dutyid="+dutyid,
				beforeSend:function(){
				},
				success:function(result){
						window.location.reload();
				}
			});

		}
	}

	//取消核定
	function cancel(dutyid){

		if (confirm('取消核定这条服务记录吗？')) {

			$.ajax({
				type: "POST",
				url: siteUrl+"index.php?app=user&ac=do&ts=cancel",
				data: "dutyid="+dutyid,
				beforeSend:function(){
				},
				success:function(result){
					if(result == '1'){
						window.location.reload();
					}
				}
			});
		}
	}

	//加星
	function star(dutyid){

			$.ajax({
				type: "POST",
				url: siteUrl+"index.php?app=user&ac=do&ts=star",
				data: "dutyid="+dutyid,
				beforeSend:function(){
				},
				success:function(result){
					if(result == '1'){
						window.location.reload();
					}
				}
			});

	}

	//去星
	function nostar(dutyid){

		$.ajax({
			type: "POST",
			url: siteUrl+"index.php?app=user&ac=do&ts=nostar",
			data: "dutyid="+dutyid,
			beforeSend:function(){
			},
			success:function(result){
				if(result == '1'){
					window.location.reload();
				}
			}
		});

	}

	$(function(){


		$('#record').on('submit', function(e) {
			var dutyid  = $('#dutyid').val();
			var idcard = $.trim($('#idcard').val());
			var username = $('#username').val();
			var groupid  = $('#gid').val();
			var cateid  = $('#cateid').val();
			var begindate  = $('#beginDate').val();
			var enddate  = $('#endDate').val();
			var period  = $('#period').val();
			var commute  = $('#commute').val();
			var job  = $('#content').val();


			if (cateid == '') {
				bootbox.alert('服务类型不能为空');
				return false;
			}

			if (groupid == '') {
				bootbox.alert('服务处所不能为空');
				return false;
			}
			if (cateid == '1' && groupid=='1') {
				bootbox.alert('服务类型与服务处所不匹配');
				return false;
			}

			if (begindate == '' ||  enddate=='') {
				bootbox.alert('起止时间不能为空');
				return false;
			}

			if (job == '<p><br></p>') {
				bootbox.alert('工作小结及注意事项必须填写');
				return false;
			}
            if(username == ''){
				bootbox.alert('姓名不能为空');
				return false;
			}


		});




	});


	$('#beginTime').datetimepicker({
		language:  'zh-CN',
		format: 'yyyy-mm-dd',
		autoclose: true,
		minView:2
	});

	$('#endTime').datetimepicker({
		language:  'zh-CN',
		format: 'yyyy-mm-dd',
		autoclose: true,
		minView:2
	});

	$('#beginDate').datetimepicker({
		language:  'zh-CN',
		format: 'yyyy-mm-dd hh:ii',
		autoclose: true,
		minView:0
	});

	$('#endDate').datetimepicker({
		language:  'zh-CN',
		format: 'yyyy-mm-dd hh:ii',
		autoclose: true,
		minView:0
	});

	$(document).ready(function(e) {
		var date = new Date();
		var vYear = date.getFullYear();
		var vMon = date.getMonth() + 1;
		var vDay = date.getDate();
		var year;
		var month;
		var day;
		var str_year;
		var str_month;
		var t_month;
		var str_day;

	//	{if $myDuty!=''}
		//	vYear = {php echo date('Y',$myDuty['begintime'])};
			//vMon  = {php echo date('m',$myDuty['begintime'])};
		//	vDay  = {php echo date('d',$myDuty['begintime'])};
		//	{/if}

				var first_year = 2017;
//起始
				var last_year = date.getFullYear();
//终止年
				var t_year
				var i;
				var r;
				var y_v;
				var m_v;
				var d_v;
//写出年的选项
				$("[data-name=year]").append('<option value=""></option>');
				for (i = last_year; i >= first_year; i--) {

					if (i != vYear) {
						$("[data-name=year]").append('<option value="' + i + '">' + i + '</option>');
					} else {
						$("[data-name=year]").append('<option value="' + i + '" selected>' + i + '</option>');
					}
				}
//写出月的选项
				$("[data-name=month]").append('<option value=""></option>');
				for (i = 1; i <= 12; i++) {
					r = i ;
					if (i != vMon) {
						$("[data-name=month]").append('<option value="' + i + '">' + r + '</option>');
					} else {
						$("[data-name=month]").append('<option value="' + i + '" selected>' + r + '</option>');
					}
				}

//初始化日的值
				getday();
//在年月的值发生变化时计算日期的天数
				$("[data-name=year]").change(function(){   getday();   });
				$("[data-name=month]").change(function(){ getday();
				});
//根据日期的天数，输出日选项

				function getday(){
					var y_v=$("[data-name=year]").val();
					var m_v=$("[data-name=month]").val()-1;
					var d_v;
					var i;
					if((y_v%100!=0&&y_v%4==0)||y_v%400==0) {
						d_v=new Array(31,29,31,30,31,30,31,31,30,31,30,31);
					}    else   {
						d_v=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
					}
					$("[data-name=day]").html("");
					$("[data-name=day]").append('<option value=""></option>');
					for(i=1;i<=d_v[m_v];i++)   {
						//if(i!=vDay)  {
						$("[data-name=day]").append('<option value="'+i+'">'+i+'</option>');
						//	}  else {
						//	$("[data-name=day]").append('<option value="'+i+'" selected>'+i+'</option>');
						//	}
					}
				}
			});

	$(function() {
		$.ms_DatePicker({
			YearSelector: "#begin_year",
			MonthSelector: "#begin_month",
			DaySelector: "#begin_day",
			FirstText: "{php date('Y-m-d',time())}"
		});
		$.ms_DatePicker({
			YearSelector: "#end_year",
			MonthSelector: "#end_month",
			DaySelector: "#end_day"
		});
	});


</script>
{php doAction('tseditor','m')}
{template footer}